
$(function(){
	leftMenu('/index.php?d=backstage&c=Rendering/userbet');
	$("aside.sidebar li:nth-child(1)").addClass("active");
	
	//窗口大小改变，重计算分辨率
	window.onresize=  resizeWidth ;
	
});

//窗口大小改变，重计算分辨率
function  resizeWidth (){
	var clientWidth;
	function windowChange(){
		clientWidth = document.documentElement.clientWidth;
		clientHeight = document.documentElement.clientHeight;
		return clientWidth,clientHeight;
	}
	windowChange();

	if(clientWidth < 1920){
		// console.log($(".scrollX_gray").find(".sequence_style_header"))
		$(".scrollX_gray .sequence_style_header").css("width","1440px");
		$(".scrollX_gray .sequence_list").css("width","1440px");
		console.log(clientWidth+"px")
	}
	else{
		$(".sequence_style_header").css("width","100%");
		$(".sequence_list").css("width","100%");
	}
	// InitTableHeight();
};


//左侧菜单点击
$(document).on("click","aside.sidebar li",function(e){
	e.stopPropagation();
	$("aside.sidebar li").removeClass("active");
	$(this).addClass("active");
});

// 1.$.ajax带json数据的异步请求
function leftMenu(_url) {
	var aj = $.ajax({
		url : _url,// 跳转到 action
		type : 'get',
		cache : false,
		dataType : 'html',
		success : function(data) {
			$("#section").unbind("click");
			$("#section").html(data);
		},
		error : function() {
			// view("异常！");
			alert("异常！");
		}
	});
};

$("#signoutBtn").click(function(){
	var token = $.cookie('token');
	$.ajax({
		url:'/index.php?d=backstage&c=user/logout',
		type:"get",
		dataType:"json",
		data:{
			"token":token
		},
		success:function(res){
			if (res.code == '0') {
				window.location.href="/view/login";
			}
		}
	});
});


//计算表格高度
function InitTableHeight(){
	if($(".content-wrapper").find(".table_compute").length == -1){
		console.log("无表格");
	}else{
		var sectionHeight = parseInt($("section").height());
		var tableOutsideHeight = 0;
		var selectHeight = 0;
		var headingHeight = 0;
		var putHeight = 0;
		var pageHeight = 0;
		var special_tablebox = 0;
		
		if($("section .sub_header").length >0){
			putHeight = parseInt($("section .sub_header:first-of-type").outerHeight(true));
		}
		if($(".content-wrapper>.content-heading").length >0){
			headingHeight = parseInt($(".content-heading:first-of-type").outerHeight(true));
		}
		if($(".content-wrapper>.filterBox").length >0){
			selectHeight = parseInt($(".filterBox:first-of-type").outerHeight(true));
		}
		if($("#page").length >0){
			pageHeight = parseInt($("#page").outerHeight(true));
		}
		if($(".special_tablebox").length >0){
			special_tablebox = parseInt($(".special_tablebox").outerHeight(true));
		}
		tableOutsideHeight = selectHeight + headingHeight + putHeight + 40;
		var tableComputeHeight =  sectionHeight - tableOutsideHeight;
		var table_headerHeight = parseInt($(".sequence_style_header").outerHeight(true));
		var table_BoxHeight = sectionHeight - tableOutsideHeight - special_tablebox - pageHeight - 25;
		var table_listHeight = table_BoxHeight - table_headerHeight;
		// $(".table_compute").css({"max-height":tableComputeHeight + "px","height":tableComputeHeight +"px"});
		// $(".table_compute>.row>div").css("height",tableComputeHeight +"px");
		$(".table_compute .table_box").css("height",table_BoxHeight + "px");
		$(".table_box .sequence_list").css("height",table_listHeight + "px");

		if($(".sequence_list .sequence_style").height() < $(".sequence_list").height()){
			$(".sequence_style_header").css("padding-right","0px")
		}else{
			$(".sequence_style_header").css("padding-right","9px")
		}
	}
};

//loading_show
var timeout_id;
function loadingShow(msg){
	if(!msg){
		msg='数据加载中，请稍后...';
	}
	$('#loadingMask span').text(msg);
	timeout_id = setTimeout("$('#loadingMask').show()",300);
	$('#loadingMask').fadeIn(300);
};
//loading_hide
function loadingHide(){
	clearTimeout(timeout_id);
	$('#loadingMask').fadeOut(300);
};

//noDataTip
function noDataTipShow(target,msg){
	var tipLength = $("#noDataTip").length;
	if(tipLength >0){
		return
	}
	var noDataTip = $("<div class='noDataTip' id='noDataTip'></div>");
	if(!msg){
		msg='抱歉，暂无数据';
	}
	noDataTip.text(msg);
	target.parent().after(noDataTip);
	$('#noDataTip').show();
};
//noDataTip_hide
function noDataTipHide(){
	if($("#noDataTip").length !=0){
		$('#noDataTip').remove();
	}
};